/**
 * 作者:夏天
 * qq:1205232048
 */
public class test {
    public static void main(String[] args) {
        int[] array = {4,4,4,4,6,4,4,4,4,4};
        int start = 0;
        int end = array.length - 1;
        sort(array, start, end);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }

    public static void sort(int[] a, int low, int high){
        int start = low;
        int end = high;
        int key = a[low];
        while (start < end){
            while (start < end && a[end] >= key){
                end--;
            }
            if(a[end] < key){
                int temp = a[end];
                a[end] = a[start];
                a[start] = temp;
            }
            while (start < end && a[start] <= key){
                start++;
            }
            if(a[start] > key){
                int temp = a[end];
                a[end] = a[start];
                a[start] = temp;
            }
        }
        if(start > low){
            sort(a, low , start-1);
        }
        if(high > end){
            sort(a, end+1, high);
        }
    }
}
